GamePanel={};
this=GamePanel;

local gameObject;
local transform;


function GamePanel.New()
    resMgr:LoadPrefab("Game",{"GamePanel"},this.OnLoadOK);

    resMgr:LoadPrefab("Bullet", {"PlayerBullet","EnemyBullet"}, this.BulletOnLoadOK);


end

function GamePanel.BulletOnLoadOK(objs)
	playerBulletPrefab = objs[0];
	enemyBulletPrefab = objs[1];

	poolMgr:CreatePool("PlayerBullet",1, 10,playerBulletPrefab);
	poolMgr:CreatePool("EnemyBullet",1, 10,enemyBulletPrefab);

    --加载玩家和敌人
    PlayerManager.New();
    EnemyFactory.New();
	
end


function GamePanel.OnLoadOK(objs)
    gameObject = newObject(objs[0]);
    transform=gameObject.transform;
    transform.position=Vector3.zero;


    this.game=transform:GetComponent('MeshRenderer').material;


    UpdateBeat:Add(this.Update);
end

function GamePanel.Update()
    this.Scroll(this.game,0.1);

end

function GamePanel.Scroll(mat,speed)
    mat.mainTextureOffset=mat.mainTextureOffset+Vector2.up*speed*Time.deltaTime;
end